﻿$(document).ready(function () {
    $(".hidden").hide();
    $(".hidden_new").hide();
    $(".showInfor_RoomType").click(function () {
        $("#info_" + $(this).attr("id")).toggle("slow");
    })

    $("#btn_add_room").click(function () {
        $("#info_new").toggle("slow");
    })

    $(".update").live("click", function () {
        var maLoaiHang = $(this).attr("id");
        var maHang = maLoaiHang.substring(0, 6);
        var maLoai = maLoaiHang.substr(6);
        var donGia = $("#donGia_" + maLoaiHang).val();
        var dataString = "maLoai=" + maLoai + "&maHang=" + maHang + "&donGia=" + donGia
        $.ajax({
            type: "GET",
            url: "Update_RoomPrice",
            data: dataString,
            dataType: 'html',
            success: function (data) {
                $("#notice_" + maLoaiHang).html(data).hide().fadeIn();
                setTimeout(function () {
                    $("#notice_" + maLoaiHang).fadeOut("slow", function () {
                        //$("#notice" + maLoai).remove();
                    });
                }, 2000);
            }
        });
    });


    $(".delete").live("click", function () {
        var maLoaiHang = $(this).attr("id");
        var maLoai = maLoaiHang.substring(0, 6);
        var maHang = maLoaiHang.substr(6);
        var dataString = "maLoai=" + maLoai + "&maHang=" + maHang
        $.ajax({
            type: "GET",
            url: "Delete_RoomPrice",
            data: dataString,
            dataType: 'html',
            success: function (data) {
                $("#notice_" + maHang + maLoai).html(data).show();
                setTimeout(function () {
                    $("#notice_" + maHang + maLoai).fadeOut("slow", function () {
                        //$("#notice" + maLoai).remove();
                    });
                }, 2000);
                location.reload();
            }
        });
    });


    $(".add").live("click", function () {
        var maLoai = $("#tenLoai_new").val();
        var maHang = $("#tenHang_new").val();
        var donGia = $("#donGia_new").val();
        var dataString = "maLoai=" + maLoai + "&maHang=" + maHang + "&donGia=" + donGia
        $.ajax({
            type: "GET",
            url: "Add_RoomPrice",
            data: dataString,
            dataType: 'html',
            success: function (data) {
                $("#notice_new").html(data).show()
                setTimeout(function () {
                    $("#notice_new").fadeOut("slow", function () {
                        //$("#notice" + maLoai).remove();
                    });
                }, 2000);
                location.reload();
            }
        });
    });


});